package com.hard;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

public class Solution {
    public static void main(String[] args) {


        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
        ConcurrentHashMap<Object, Object> concurrentHashMap = new ConcurrentHashMap<>();
    }

    public static void heapSort(int[] arr){
        for(int i = arr.length - 1;i>=0;i--){
            heapAdjest(arr,i,arr.length);
        }
        for(int i = arr.length-1;i>=0;i--){
            int temp = arr[0];
            arr[0] = arr[i];
            arr[i] = temp;
            heapAdjest(arr,0,i);
        }
    }
    public static void heapAdjest(int[] arr,int parent,int length){
        int temp = arr[parent];
        int child = parent * 2 + 1;
        while (child<length){
            if(child+1<length&&arr[child+1]>arr[child]){
                child++;
            }
            if(temp>=arr[child]){
                break;
            }
            arr[parent] = arr[child];
            parent = child;
            child = parent * 2 + 1;
        }
        arr[parent] = temp;
    }
}
